package day_2022_9_to_12.Day;

/**
 * @author haomin
 * @date 2022/11/09 09:28
 **/
public class Day66_1_Num764_OrderOfLargestPlusSign {
    class Solution {
        public int orderOfLargestPlusSign(int n, int[][] mines) {
            int ans=0,grid[][]=new int[n][n];
            for(int i=0;i<mines.length;i++){grid[mines[i][0]][mines[i][1]]=1;}
            for(int i=0;i<n;i++){for(int j=0;j<n;j++){ans=Math.max(ans,find(grid,i,j,n));}}
            return ans;
        }
        int find(int grid[][],int x,int y,int n){
            if(grid[x][y]==1){return 0;}
            int k=1;
            while(true){
                if(x-k<0||grid[x-k][y]==1||x+k==n||grid[x+k][y]==1||y-k<0||grid[x][y-k]==1||y+k==n||grid[x][y+k]==1){break;}
                k++;
            }
            return k;
        }
    }
}